<?php

/*
|--------------------------------------------------------------------------
| Routes File
|--------------------------------------------------------------------------
|
| Here is where you will register all of the routes in an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| This route group applies the "web" middleware group to every route
| it contains. The "web" middleware group is defined in your HTTP
| kernel and includes session state, CSRF protection, and more.
|
*/


Route::group(['middleware' => 'web'], function () {

    // show login form
    $this->get('login', 'Auth\AuthController@showLoginForm');
    // do login
    $this->post('login', 'Auth\AuthController@login');
    //do logout
    $this->get('logout', 'Auth\AuthController@logout')->name("logout");
    // home
    Route::get('/', 'HomeController@index');
    // user

    Route::group(['prefix' => 'api'], function () {
        Route::get('user/managers', 'UserController@getCanteenManagers');
        Route::resource('user', 'UserController',['only'=>['index','store','update','show']]);
        Route::resource('canteen', 'CanteenController',['only'=>['index','store','update','show']]);
        Route::resource('category', 'CategoryController',['only'=>['index','store','update','show']]);

        Route::get('product/categories', 'ProductController@categories');
        Route::get('statistics', 'HomeController@statistics');
        Route::resource('product', 'ProductController',['only'=>['index','store','update','show']]);
        Route::resource('sku', 'SkuController',['only'=>['index','store','show']]);
        Route::resource('record', 'RecordController',['only'=>['index','store','update','show']]);
    });


    Route::group(['prefix' => 'admin'], function () {
        Route::get('/', 'HomeController@index');
    });


    Route::group(['prefix' => 'manager', 'namespace' =>'Manager'], function () {
        Route::get('/', 'HomeController@index');
    });



});
